package util;

import javax.swing.JProgressBar;

public class ProgressThread implements Runnable {
    private JProgressBar progressBar;

    int length, unitTime;

    public ProgressThread(JProgressBar progressBar, int length, int unitTime) {
        this.progressBar = progressBar;
        this.length = length;
        this.unitTime = unitTime;
    }

    public void run() {
        progressBar.setValue(0);
        for (int i = 0; i < 100; i++) {
            progressBar.setValue(i);
            System.out.println("setting progress......");
            try {
               Thread.sleep((int) ((double) length / 100.0 * unitTime));
            } catch (Exception e) {
                System.err.println("ProgressBar thread error.....");
                e.printStackTrace();
            }
        }
    }
}
